package il.ac.braude.sona.gui.forms.questions;

import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;

/**
 * Class for representing a question button
 * @author  Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
@SuppressWarnings("serial")
public class QButton extends FormQuestion {
	/**
	 * button we will use for the class
	 */
	JButton button;
	/**
	 * initialize a new button and sets the action listener for the button
	 * @param buttonText - button name
	 * @param control  - action listener for the button
	 */
	public QButton(String buttonText,ActionListener control) {
		super(BoxLayout.X_AXIS);
		button = new JButton(buttonText);
		button.addActionListener(control);
		add(button);
	}

	public void disapearButton() {
		button.setVisible(false);
	}
	public void showButton() {
		button.setVisible(true);
	}
	
	@Override
	public void setDefaultAnswer(Object defaultAnswer) {
		button.setText(defaultAnswer.toString());
	}

	@Override
	public Object getAnswer() {
		return button.getText();
	}
}
